<?php
header('Content-Type: text/html; charset=utf-8');

include "../../config/configuration.php";
require_once MODELS_DIR . "DataLayer.php";
require_once MODELS_DIR . "ProcessingDate.php";
require_once LIBRARIES_DIR . "Mysql.php";
require_once LIBRARIES_DIR . "Util.php";

$dir = opendir(CONTROLLERS_DIR);

while( $classe = readdir($dir) )
{
	if(preg_match("'^.*\.php'", $classe))
	{
		require_once(CONTROLLERS_DIR.$classe);	
	}
}
closedir($dir);
session_start();

$db_Mysql = new Mysql(HOST_DB_MYSQL, USER_DB_MYSQL, PASS_DB_MYSQL, NAME_DB_MYSQL, false) or exit ("Não foi possível conectar ao banco de dados!");


$acceptFunctions = Array("getProjects","login","getTasks","getNotifications","changeStateTask", "getTaskStates");
preg_match("(^[a-zA-Z]+$)",$_GET['f'],$match);

if(count($match) > 0)
	$nameFunction = $match[0];

if(in_array($nameFunction,$acceptFunctions)){
	parse_str(addslashes($_SERVER['QUERY_STRING']), $obj);
	unset($obj["f"]);
	echo $temp = C_AppDesktop::$nameFunction($obj);
	
	//echo "<pre>";
	//print_r(json_decode($temp));
}else{
	echo "Erro!";
}
?>